﻿@model List<ADZ_GoodsIMG>
@{
    Layout = null;
    var viewModel = Model ?? new List<ADZ_GoodsIMG>();
}

<link href="~/Css/self-upload.css" rel="stylesheet" />
<div class="text-item">
    <div class="fm-item">
        <span style="vertical-align: middle;">可上传3个图片，支持png和jpg文件，最大不超过8M 物料图片建议200K以内的正方形图片</span>
    </div>

    <div class="fm-item">
        <div class="thumb-wrap upload-thumb-wrap" id="thumb-wrap">

            @for (int index = 0; index < viewModel.Count; index++)
            {
                <input type="hidden" name="aDZ_GoodsIMGs[@index].seq_id" value="@viewModel[index].seq_id" />
            }

            @{
                var goodsIMGs = viewModel.OrderBy(t => t.sort_NO).ToList();
                goodsIMGs = goodsIMGs ?? new List<ADZ_GoodsIMG>();
                for (int index = 0; index < goodsIMGs.Count; index++)
                {
                    var item = goodsIMGs[index];

                    <div class="thumb-item hadupload">
                        <div class="thumb-item-wrap">
                            <a href="javacript:void(0);" class="img-wrap">
                                <img class="thumb-img" src="@ImageFileBiz.GetImg(item.img_url, "small")" style="width: 100px;margin:auto;">
                            </a>
                            <label class="file-radio"><input type="radio" class="check-radio" value="@item.img_url" name="first_img" @(item.sort_NO == 1 ? "checked" : "") />设为首图</label>
                            <input type="hidden" name="aDZ_GoodsIMGs[@index].img_url" value="@item.img_url" />
                            <input type="hidden" name="aDZ_GoodsIMGs[@index].img_type" value="@item.img_type" />
                            <input type="hidden" name="aDZ_GoodsIMGs[@index].sort_NO" value="@item.sort_NO" />
                            <input type="hidden" name="aDZ_GoodsIMGs[@index].seq_id" value="@item.seq_id" />
                        </div>
                        <div class="clear info">
                            <a href="javascript:void(0);" class="link">删除</a>
                            <p class="name">@item.img_url</p>
                        </div>
                    </div>
                }
            }
            @if (goodsIMGs.Count < 3)
            {
                <div class="thumb-item">
                    <div class="thumb-item-wrap">
                        <div class="thumb-img-box">
                            <input class="file-input" name="file" type="file" onchange=" change(this,$(this).parents('.thumb-img-box').siblings('.img-wrap').find('img').get(0)) " _name="img2">
                            <i class="iconfont add-icon"> + </i>
                        </div>
                        <a href="javacript:void(0);" class="img-wrap">
                            <img class="thumb-img" src="">
                            <img class="original-img" src="" style="display:none;">
                        </a>
                        <label class="file-radio" style="display:none"><input type="radio" class="check-radio" value="" name="first_img" />设为首图</label>
                    </div>
                    <div class="clear info">
                        <a href="javascript:void(0);" class="link">删除</a><p class="name">...</p>
                    </div>
                </div>
            }
        </div>
    </div>
</div>

<!-- 图片逻辑 -->
<script src="~/Js/self-upload.js"></script>
